#!usr/bin/env python  
# -*- coding:utf-8 _*-
""" 
@author:robot
@file: sync_sink_redis.py 
@version:
@time: 2022/01/07 
"""
from TapClientCore.T04_logic.Dag01.node.node_base import NodeBase, TapdataNoThisDataSource


class SyncSinkRedisNode(NodeBase):

    def __init__(self, name, redisKey: str):
        self.id = self.newId
        self.name = name
        self.redisKey = redisKey
        self.tableId = None
        self.attribute = self.sole()

    def sole(self):
        response = self.TM.get_connections_by_name(self.name)
        this_node = {
            "connectionId": response["data"][0]["id"],
            "id": self.id,
            # 节点名称为表名
            "name": self.name,
            "inputLanes": [],
            "outputLanes": [],
            'redisKey': self.redisKey,
            'redisKeyPrefix': '',
            "type": "redis"
        }
        return this_node
